package com.xuanyang.dormrepair.config;

import com.xuanyang.dormrepair.utils.RestResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @AUTHOR soft
 * @DATE 2018/12/21 16:20
 * @DESCRIBE
 */
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public RestResponse sh(ServiceException e) {
        log.error(e.getMessage());
        return RestResponse.fail(e.getMessage());
    }
}
